package com.ants.auth.service;

import com.ants.auth.utils.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.util.*;

/**
 * @author 蚂蚁会花呗
 * @create 2025/5/29 15:29
 * 初始化一些资源
 */
@Service
public class ResourceServiceImpl {

    private static final String GATEWAY_RESOURCE_ROLE_KEY = "gateway:resource";

    private Map<String, List<Object>> resourceRolesMap;

    @Autowired
    private RedisUtils redisUtils;



    @PostConstruct
    public void initData() {
        resourceRolesMap = new TreeMap<>();
        resourceRolesMap.put("/ants-product-dev/product/**", Arrays.asList("ROLE_ADMIN"));
        resourceRolesMap.put("/ants-product-dev/test/**", Arrays.asList("ROLE_TEST"));
        redisUtils.rightPush(GATEWAY_RESOURCE_ROLE_KEY,resourceRolesMap,0);
    }

}
